class Solution {
public:
    int mySqrt(int x) {
        if (x <= 1)return x;
        long long  ans = x;
        while (ans > x / ans)
        {
            ans = (ans + x / ans) / 2;
        }
        return ans;
    }
};